// import Mock from 'mockjs'

/** 获取url参数，传入完整url字符串，输出参数值 */
function getValue (url, name) {
  var match = url.match(/\?/)
  if (match !== null) {
    var searchPar = url.substr(url.match(/\?/).index + 1)
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i")
    return unescape(searchPar.match(reg)[2])
  } else {
    return undefined
  }
}

Mock.mock(/test.com/, function (options) {
  var url = options.url
  var value = getValue (url, 'value')
  var image = Mock.Random.dataImage('300x300', value)
  console.dir(options)
  return {img: image}
})
// Mock.mock(/test.cm/, function (options) {
//   var url = options.url
//   var value = getValue (url, 'value')
//   var image = Mock.Random.dataImage('300x300', value)
//   console.dir(options)
//   return {img: image}
// })
